import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

# 打开浏览器
service = Service(r'D:\Python3.14\chromedriver.exe')
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=service, options=chrome_options)   # 创建浏览器对象
# 输入访问网址
driver.get("http://121.43.169.97:8848/pageA.html")


"""通过id属性定位页面元素"""
driver.find_element(by=By.ID, value="userA").send_keys("admin")
driver.find_element(by=By.ID, value="passwordA").send_keys("123456")
driver.find_element(by=By.ID, value="telA").send_keys("13633089805")
driver.find_element(by=By.ID, value="selectA").send_keys("广州")

"""通过name属性定位页面元素"""
# driver.find_element(by=By.NAME, value="userA").send_keys("admin")
# driver.find_element(by=By.NAME, value="passwordA").send_keys("123456")
# driver.find_element(by=By.NAME, value="telA").send_keys("13633089805")
# driver.find_element(by=By.NAME, value="emailA").send_keys("2218136327@qq.com")
# driver.find_element(by=By.NAME, value="selecta").send_keys("深圳")

"""通过class属性定位页面元素"""
# driver.find_element(by=By.CLASS_NAME, value="telA").send_keys("13633089805")
# driver.find_element(by=By.CLASS_NAME, value="emailA").send_keys("2218136327@qq.com")

"""通过标签名属性定位页面元素"""   # 不常用，因为标签名容易重复
# driver.find_element(By.TAG_NAME, "input").send_keys("admin")
# driver.find_element(By.TAG_NAME, "input").send_keys("123456")

"""通过超链接定位页面元素"""
# driver.find_element(By.LINK_TEXT, "百度").click()
# # 放大浏览器
# driver.miximize_window()

"""通过部分超链接定位页面元素"""    # 获取的是超链接的部分文本信息
# driver.find_element(By.PARTIAL_LINK_TEXT, "网站").click()

